/* 路由中间件检测
 * @Author: Leil 
 * @Date: 2018-08-19 00:44:07 
 * @Last Modified by: Leil
 * @Last Modified time: 2018-09-06 10:07:52
 */
module.exports = {
    checkLogin: function checkLogin(req, res, next) {
        console.log('middleware checkLogin...')
        console.log(req.session.user)
        if (!req.session.user) {
            req.flash('error', '未登录')
            return res.redirect('/login')
        }
        next()
    },

    // checkNotLogin: function checkNotLogin(req, res, next) {
    //     if (req.session.user) {
    //         req.flash('error', '已登录')
    //         return res.redirect('back') // 返回之前的页面
    //     }
    //     next()
    // }
}